<template>
  <view class="login">
    <image class="login-bg" mode="widthFix" src="../../static/login_bg.png"></image>
    <view class="title">
      欢迎登录
      <view class="strong">XXX平台</view>
    </view>
    <view class="form">
      <view class="form-item">
        <input class="form-input" placeholder="请输入用户名"/>
      </view>
      <view class="form-item">
        <input class="form-input" placeholder="请输入密码" :password="showPassword" />
        <view class="eye" @tap="showPassword = !showPassword">
          <image :src="!showPassword ? '../../static/eye-close.png' : '../../static/eye.png'" mode="widthFix" class="eye-icon"></image>
        </view>
      </view>
      <view class="update-pwd">
        <text>修改密码</text>
      </view>
      <button class="login-button" type="primary" @tap="login">登录</button>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      showPassword: true
    }
  },
  onLoad() {
    this.init()
  },
  methods: {
    init(){
      // 获取当前页面实例
      const pages = getCurrentPages();
      // 获取当前页面的实例
      const currentPage = pages[pages.length - 1];
      // 获取页面路径
      const pagePath = currentPage.route;
      console.log('当前页面实例:',currentPage,'当前页面路径为：' + pagePath);
    },
    login(){
      uni.reLaunch({
        url:'/pages/index/index'
      })
    }
  }
}
</script>

<style lang="less">
page {
  background: #fff;
}
.login{
  position: relative;
  padding: 0 52rpx;
  padding-top: 260rpx;
  .login-bg{
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    width: 100%;
    z-index: 0;
  }
  .title {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    font-size: 48rpx;
    font-weight: 600;
    color: #17204d;
    line-height: 66rpx;
    .strong {
      color: #4c65f5;
    }
  }
  .form{
    padding-top: 50rpx;
    .form-item{
      display: flex;
      align-items: center;
      border-bottom: 1rpx solid #ccc;
      padding-top: 28rpx;
      margin-bottom: 28rpx;
      .form-input{
        flex: 1;
        height: 56rpx;
      }
      .eye{
        width: 48rpx;
        height: 48rpx;
        .eye-icon{
          width: 100%;
          height: 100%;
        }
      }
    }
    .update-pwd{
      padding: 28rpx 0;
      text-align: right;
      line-height: 32rpx;
      color: #4c65f5;
      margin-bottom: 50rpx;
    }
    .login-button{
      background: linear-gradient(270deg, #6e9bff 0%, #4761f4 100%) rgba(255, 255, 255, 0.7);
      border-radius: 46rpx;
      border-color: transparent;
    }
  }
}
</style>